import Vue from 'vue'
import VueRouter from 'vue-router'
// import { component } from 'vue/types/umd'

Vue.use(VueRouter)

export const routes = [{
  path: '/',
  redirect: '/login'
},
{
  path: '/home',
  name: 'home',
  redirect: '/projectMain'
},
{
  path: '/login',
  name: 'login',
  component: () => import('../views/Login/Login.vue')
},
{
  path: '/findPassword',
  name: 'findPassword',
  component: () => import('../pages/findPassword/findPassword.vue')
},
{
  path: '/testApp',
  name: 'testApp',
  component: () => import('@/views/testApp')
}
]

// 项目内路由
export const projectManageRoutes = [
  {
    path: '/projectManage',
    name: 'projectManage',
    redirect: '/projectInfoManage',
    component: () => import('../views/Project/project.vue'),
    children: [
      // {
      //   path: '/innerHomePage',
      //   name: 'innerHomePage',
      //   meta: {
      //     name: '首页',
      //     roles: [1]
      //   },
      //   component: () => import('../projectPages/innerHomePage')
      // },
      {
        path: '/projectInfoManage',
        name: 'projectInfoManage',
        meta: {
          name: '项目信息管理',
          roles: [1]
        },
        redirect: '/projectInfoManageMain',
        component: () => import('../projectPages/projectInfoManage'),
        children: [{
          path: '/projectInfoManageMain',
          meta: {
            authority: 'project:info:detail',
            nav: 'projectInfoManage'
          },
          component: () => import('../projectPages/projectInfoManage/components/projectInfoManageMain.vue')
        }]
      },
      {
        path: '/sensorManage',
        name: 'sensorManage',
        redirect: '/baseHole',
        component: () => import('../projectPages/sensorManage'),
        meta: {
          name: '传感器管理',
          roles: [1],
          childTitle: [
            '基坑',
            '塔吊',
            '高支模'
          ],
          childPath: ['/baseHole', '/towerCrane', '/highFormwrokSup']
        },
        children: [
          {
            path: '/baseHole',
            name: 'baseHole',
            redirect: '/baseHoleMain',
            component: () => import('../projectPages/sensorManage/baseHole'),
            children: [
              {
                path: '/baseHoleMain',
                name: 'baseHoleMain',
                meta: {
                  authority: 'project:view:detail',
                  nav: 'baseHole',
                  fatherPath: 'sensorManage'
                },
                component: () => import('../projectPages/sensorManage/baseHole/components/baseHoleMain.vue')
              },
              {
                path: '/addbaseHoleSensor',
                name: 'addbaseHoleSensor',
                meta: {
                  authority: 'project:view:update',
                  nav: 'baseHole',
                  fatherPath: 'sensorManage'
                },
                component: () => import('../projectPages/sensorManage/baseHole/components/addSensor.vue')
              }
            ]
          },
          {
            path: '/towerCrane',
            name: 'towerCrane',
            redirect: '/towerCraneMain',
            component: () => import('../projectPages/sensorManage/towerCrane'),
            children: [
              {
                path: '/towerCraneMain',
                name: 'towerCraneMain',
                meta: {
                  authority: 'project:view:detail',
                  nav: 'towerCrane',
                  fatherPath: 'sensorManage'
                },
                component: () => import('../projectPages/sensorManage/towerCrane/components/towerCraneMain.vue')
              },
              {
                path: '/addtowerCraneSensor',
                name: 'addtowerCraneSensor',
                meta: {
                  authority: 'project:view:update',
                  nav: 'towerCrane',
                  fatherPath: 'sensorManage'
                },
                component: () => import('../projectPages/sensorManage/towerCrane/components/addSensor.vue')
              }
            ]
          },
          {
            path: '/highFormwrokSup',
            name: 'highFormwrokSup',
            redirect: '/highFormMain',
            component: () => import('../projectPages/sensorManage/highFormwrokSup'),
            children: [
              {
                path: '/highFormMain',
                name: 'highFormMain',
                meta: {
                  authority: 'project:view:detail',
                  nav: 'highFormwrokSup',
                  fatherPath: 'sensorManage'
                },
                component: () => import('../projectPages/sensorManage/highFormwrokSup/components/highFormMain.vue')
              },
              {
                path: '/addhighFormSensor',
                name: 'addhighFormSensor',
                meta: {
                  authority: 'project:view:update',
                  nav: 'highFormwrokSup',
                  fatherPath: 'sensorManage'
                },
                component: () => import('../projectPages/sensorManage/highFormwrokSup/components/addSensor.vue')
              }
            ]
          }
        ]
      },
      {
        path: '/actionCapture',
        name: 'actionCapture',
        redirect: '/actionMain',
        meta: {
          name: '行为识别',
          roles: [1]
        },
        component: () => import('../projectPages/actionCapture'),
        children: [
          {
            path: '/actionMain',
            meta: {
              authority: 'project:discern:detail',
              nav: 'actionCapture'
            },
            component: () => import('../projectPages/actionCapture/components/actionMain.vue')
          },
          {
            path: '/areaManage',
            meta: {
              authority: 'project:discern:detail',
              nav: 'actionCapture'
            },
            component: () => import('../projectPages/actionCapture/components/areaManage.vue')
          },
          {
            path: '/addCamera',
            meta: {
              authority: 'project:discern:update',
              nav: 'actionCapture'
            },
            component: () => import('../projectPages/actionCapture/components/addCamera.vue')
          }
        ]
      },
      {
        path: '/epidmicControl',
        name: 'epidmicControl',
        meta: {
          name: '疫情防控',
          roles: [1]
        },
        redirect: '/epControlMain',
        component: () => import('../projectPages/epidmicControl'),
        children: [
          {
            path: '/epControlMain',
            meta: {
              authority: 'project:prevention:detail',
              nav: 'epidmicControl'
            },
            component: () => import('../projectPages/epidmicControl/components/epControlMain')
          },
          {
            path: '/addEpControlCamera',
            meta: {
              authority: 'project:prevention:update',
              nav: 'epidmicControl'
            },
            component: () => import('../projectPages/epidmicControl/components/addEpControlCamera')
          }
        ]
      },
      {
        path: '/spectrumScan',
        name: 'spectrumScan',
        redirect: '/bdMaterialsDete',
        meta: {
          name: '光谱扫描',
          roles: [1],
          childTitle: [
            '建材检测',
            '基坑扫描'
          ],
          childPath: ['/bdMaterialsDete', '/baseHoleScan']
        },
        component: () => import('../projectPages/spectrumScan'),
        children: [{
          path: '/bdMaterialsDete',
          name: 'bdMaterialsDete',
          redirect: '/bdMaterialsDeteMain',
          component: () => import('../projectPages/spectrumScan/bdMaterialsDete'),
          children: [{
            path: '/bdMaterialsDeteMain',
            meta: {
              authority: 'project:spectral:detail',
              nav: 'bdMaterialsDete',
              fatherPath: 'spectrumScan'
            },
            component: () => import('../projectPages/spectrumScan/bdMaterialsDete/components/bdMaterialsDeteMain.vue')
          }]
        },
        {
          path: '/baseHoleScan',
          name: 'baseHoleScan',
          component: () => import('../projectPages/spectrumScan/baseHoleScan'),
          redirect: '/baseHoleScanMain',
          children: [
            {
              path: '/baseHoleScanMain',
              name: 'baseHoleScanMain',
              meta: {
                authority: 'project:spectral:detail',
                nav: 'baseHoleScan',
                fatherPath: 'spectrumScan'
              },
              component: () => import('../projectPages/spectrumScan/baseHoleScan/components/baseHoleScanMain')
            },
            {
              path: '/addBaseHoleScan',
              name: 'addBaseHoleScan',
              meta: {
                authority: 'project:spectral:detail',
                nav: 'baseHoleScan'
              },
              component: () => import('../projectPages/spectrumScan/baseHoleScan/components/addBaseHoleScan')
            }
          ]
        }]
      },
      {
        path: '/5gNetManage',
        name: '5gNetManage',
        redirect: '/baseNetManage',
        component: () => import('../projectPages/5gNetManage'),
        meta: {
          name: '5G网络管理',
          roles: [1],
          childTitle: [
            '5G基站管理',
            '5GWIFI管理'
          ],
          childPath: ['/baseNetManage', '/wifiManage']
        },
        children: [
          {
            path: '/baseNetManage',
            name: 'baseNetManage',
            redirect: '/baseNetManageMain',
            component: () => import('../projectPages/5gNetManage/baseNetManage'),
            children: [{
              path: '/baseNetManageMain',
              meta: {
                authority: 'project:network:detail',
                nav: 'baseNetManage',
                fatherPath: '5gNetManage'
              },
              component: () => import('../projectPages/5gNetManage/baseNetManage/components/baseNetManageMain.vue')
            }]
          },
          {
            path: '/wifiManage',
            name: 'wifiManage',
            redirect: '/wifiManageMain',
            component: () => import('../projectPages/5gNetManage/wifiManage'),
            children: [{
              path: '/wifiManageMain',
              meta: {
                authority: 'project:network:detail',
                nav: 'wifiManage',
                fatherPath: '5gNetManage'
              },
              component: () => import('../projectPages/5gNetManage/wifiManage/components/wifiManageMain.vue')
            }]
          }
        ]
      },
      {
        path: '/projectRoleManage',
        name: 'projectRoleManage',
        meta: {
          name: '项目员工管理',
          roles: [1]
        },
        redirect: '/innerRoleManageMain',
        component: () => import('../projectPages/projectRoleManage'),
        children: [
          {
            path: '/innerRoleManageMain',
            name: 'innerRoleManageMain',
            meta: {
              authority: 'project:user:detail',
              nav: 'projectRoleManage'
            },
            component: () => import('../projectPages/projectRoleManage/components/roleManageMain')
          },
          {
            path: '/innerAddRole',
            name: 'innerAddRole',
            meta: {
              authority: 'project:user:update',
              nav: 'projectRoleManage'
            },
            component: () => import('../projectPages/projectRoleManage/components/addRole')
          }
        ]
      }
    ]
  }
]

// 项目外路由
export const asyncRoutes = [
  ...projectManageRoutes,
  {
    path: '/home',
    name: 'home',
    // redirect: '/projectMain',
    component: () => import('../views/Home/home.vue'),
    children: [
      // {
      //   path: '/homePage',
      //   name: 'homePage',
      //   component: () => import('../pages/homePage/homePage.vue'),
      //   meta: {
      //     name: '首页',
      //     roles: [1]
      //   }
      // },
      {
        path: '/Project',
        name: 'Project',
        redirect: '/projectMain',
        component: () => import('../pages/Project/Project.vue'),
        meta: {
          name: '项目管理',
          roles: [1]
        },
        children: [
          {
            meta: {
              authority: 'project:manager:detail',
              nav: 'Project'
            },
            path: '/projectMain',
            name: 'projectMain',
            component: () => import('../pages/Project/page/ProjectMain.vue')
          },
          {
            meta: {
              authority: 'project:manager:detail',
              nav: 'Project'
            },
            path: '/projectView',
            name: 'projectView',
            component: () => import('../pages/Project/page/viewForm.vue')
          },
          {
            meta: {
              authority: 'project:manager:update',
              nav: 'Project'
            },
            path: '/addProject',
            name: 'addProject',
            component: () => import('../pages/Project/page/addProject.vue')
          }
        ]
      },
      {
        path: '/sensor',
        name: 'sensor',
        redirect: '/sensorHome',
        component: () => import('../pages/sensor/sensor.vue'),
        meta: {
          name: '传感器类型管理',
          roles: [1]
        },
        children: [
          {
            path: '/addSensorType',
            name: 'addSensorType',
            meta: {
              authority: 'deviceType:manager:update',
              nav: 'sensor'
            },
            component: () =>
              import('../pages/sensor/components/addSensorType.vue')
          },
          {
            path: '/sensorHome',
            name: 'sensorHome',
            meta: {
              authority: 'deviceType:manager:detail',
              nav: 'sensor'
            },
            component: () => import('../pages/sensor/components/sensorHome.vue')
          },
          {
            meta: {
              authority: 'deviceType:manager:update',
              nav: 'sensor'
            },
            path: '/writeSensorType',
            name: 'writeSensorType',
            component: () =>
              import('../pages/sensor/components/writeSensorType.vue')
          }
        ]
      },
      {
        path: '/scene',
        name: 'scene',
        redirect: '/sceneManagement',
        component: () => import('../pages/scene/scene.vue'),
        meta: {
          name: '场景类型管理',
          roles: [1]
        },
        children: [
          {
            path: '/addScene',
            name: 'addScene',
            meta: {
              authority: 'sceneType:manager:update',
              nav: 'scene'
            },
            component: () => import('../pages/scene/components/addScene.vue')
          },
          {
            path: '/sceneManagement',
            name: 'sceneManagement',
            meta: {
              authority: 'sceneType:manager:detail',
              nav: 'scene'
            },
            component: () =>
              import('../pages/scene/components/sceneManagement.vue')
          },
          {
            path: '/writeScene',
            name: 'writeScene',
            meta: {
              authority: 'sceneType:manager:update',
              nav: 'scene'
            },
            component: () => import('../pages/scene/components/writeScene.vue')
          }
        ]
      },
      {
        path: '/ProjectDepartment',
        name: 'ProjectDepartment',
        redirect: '/projectDepart',
        component: () =>
          import('../pages/ProjectDepartment/ProjectDepartment.vue'),
        meta: {
          name: '项目组织管理',
          roles: [1],
          childTitle: [
            '部门',
            '角色'
          ],
          childPath: ['/projectDepart', '/projectRole']
        },
        children: [
          {
            path: '/projectDepart',
            name: 'projectDepart',
            component: () => import('../pages/ProjectDepartment/projectDepart'),
            redirect: '/projectDepartMain',
            children: [
              {
                path: '/projectDepartMain',
                name: 'projectDepartMain',
                meta: {
                  fatherPath: 'ProjectDepartment',
                  authority: 'depart:manager:detail',
                  nav: 'projectDepart'
                },
                component: () => import('../pages/ProjectDepartment/projectDepart/components/projectDepartMain')
              },
              {
                path: '/addProjectDepart',
                name: 'addProjectDepart',
                meta: {
                  fatherPath: 'ProjectDepartment',
                  authority: 'depart:manager:update',
                  nav: 'projectDepart'
                },
                component: () => import('../pages/ProjectDepartment/projectDepart/components/addProjectDepart.vue')
              }
            ]
          },
          {
            path: '/projectRole',
            name: 'projectRole',
            component: () => import('../pages/ProjectDepartment/projectRole'),
            redirect: '/projectRoleMain',
            children: [
              {
                path: '/projectRoleMain',
                name: 'projectRoleMain',
                meta: {
                  fatherPath: 'ProjectDepartment',
                  authority: 'user:permissions:detail',
                  nav: 'projectRole'
                },
                component: () => import('../pages/ProjectDepartment/projectRole/components/projectRoleMain')
              },
              {
                path: '/addProjectRole',
                name: 'addProjectRole',
                meta: {
                  fatherPath: 'ProjectDepartment',
                  authority: 'user:permissions:update',
                  nav: 'projectRole'
                },
                component: () => import('../pages/ProjectDepartment/projectRole/components/addProjectRole.vue')
              }
            ]
          }
        ]
      },
      {
        path: '/file',
        name: 'file',
        // redirect: '/professorData',
        component: () => import('../pages/file/file.vue'),
        meta: {
          name: '资料管理',
          roles: [1],
          childTitle: [
            '专家资料',
            '学习天地'
          ],
          childPath: ['/professorData', '/studyArea']
        },
        children: [
          {
            path: '/professorData',
            name: 'professorData',
            component: () => import('../pages/file/professorData'),
            redirect: '/professorMain',
            children: [
              {
                path: '/professorMain',
                name: 'professorMain',
                meta: {
                  fatherPath: 'file',
                  authority: 'learn:expert:down',
                  nav: 'professorData'
                },
                component: () => import('../pages/file/professorData/components/professorMain')
              },
              {
                path: '/category',
                name: 'category',
                meta: {
                  fatherPath: 'file',
                  authority: 'learn:expert:category',
                  nav: 'professorData'
                },
                component: () => import('../pages/file/professorData/components/CategoryManagement')
              }
            ]
          },
          {
            path: '/studyArea',
            name: 'studyArea',
            component: () => import('../pages/file/studyArea'),
            redirect: '/studyMain',
            children: [
              {
                path: '/studyMain',
                name: 'studyMain',
                meta: {
                  fatherPath: 'file',
                  authority: 'learn:world:down',
                  nav: 'studyArea'
                },
                component: () => import('../pages/file/studyArea/components/studyMain')
              },
              {
                path: '/category2',
                name: 'category2',
                meta: {
                  fatherPath: 'file',
                  authority: 'learn:world:update',
                  nav: 'studyArea'
                },
                component: () => import('../pages/file/studyArea/components/CategoryManagement')
              }
            ]
          }
        ]
      },
      {
        path: '/dataModel',
        name: 'dataModel',
        component: () => import('../pages/dataModel'),
        redirect: '/dataMain',
        meta: {
          name: '数据模型',
          roles: [1]
        },
        children: [
          {
            path: '/dataMain',
            name: 'dataMain',
            meta: {
              authority: 'learn:model:detail',
              nav: 'dataModel'
            },
            component: () => import('../pages/dataModel/components/dataMain')
          },
          {
            path: '/addModel',
            name: 'addModel',
            meta: {
              authority: 'learn:model:update',
              nav: 'dataModel'
            },
            component: () => import('../pages/dataModel/components/addModel')
          }
        ]
      },
      {
        path: '/tunnel',
        name: 'tunnel',
        redirect: '/tunnelHome',
        component: () => import('../pages/tunnel/tunnel.vue'),
        meta: {
          name: '隧道桥梁',
          roles: [1]
        },
        children: [
          {
            path: '/tunnelHome',
            name: 'tunnelHome',
            meta: {
              authority: 'tunnel:bridge:down',
              nav: 'tunnel'
            },
            component: () => import('../pages/tunnel/components/tunnelHome.vue')
          },
          {
            path: '/CategoryManagement',
            name: 'CategoryManagement',
            meta: {
              authority: 'tunnel:bridge:category',
              nav: 'tunnel'
            },
            component: () => import('../pages/tunnel/components/CategoryManagement.vue')
          }
        ]
      },
      {
        path: '/cityGovern',
        name: 'cityGovern',
        component: () => import('../pages/cityGovern'),
        meta: {
          name: '市容治理',
          roles: [1]
        },
        redirect: '/cityGovernMain',
        children: [
          {
            path: '/cityGovernMain',
            name: 'cityGovernMain',
            meta: {
              authority: 'city:manager:down',
              nav: 'cityGovern'
            },
            component: () => import('../pages/cityGovern/components/cityGovernMain')
          },
          {
            path: '/cityCategory',
            name: 'cityCategory',
            meta: {
              authority: 'city:manager:category',
              nav: 'cityGovern'
            },
            component: () => import('../pages/cityGovern/components/CategoryManagement')
          }
        ]
      },
      {
        path: '/dangerAudit',
        name: 'dangerAudit',
        component: () => import('../pages/dangerAudit/dangerAudit.vue'),
        redirect: '/dangerAuditMain',
        meta: {
          name: '隐患内容审核',
          roles: [1]
        },
        children: [
          {
            path: '/dangerAuditMain',
            name: 'dangerAuditMain',
            meta: {
              authority: 'safe:hidden:detail',
              nav: 'dangerAudit'
            },
            component: () =>
              import('../pages/dangerAudit/pages/dangerAuditMain.vue')
          }
        ]
      },
      {
        path: '/userManage',
        name: 'userManage',
        component: () => import('../pages/userManage/userManage.vue'),
        redirect: '/specialUserManage',
        meta: {
          name: '特殊用户管理',
          roles: [1]
        },
        children: [
          {
            path: '/specialUserManage',
            name: 'specialUserManage',
            meta: {
              authority: 'special:user:detail',
              nav: 'userManage'
            },
            component: () =>
              import('../pages/userManage/page/specialUserManage.vue')
          },
          {
            path: '/editUser',
            name: 'editUser',
            meta: {
              authority: 'special:user:update',
              nav: 'userManage'
            },
            component: () => import('../pages/userManage/page/editUser.vue')
          },
          {
            path: '/addUser',
            name: 'addUser',
            meta: {
              authority: 'special:user:update',
              nav: 'userManage'
            },
            component: () => import('../pages/userManage/page/addUser.vue')
          },
          {
            path: '/organizationManage',
            name: 'organizationManage',
            meta: {
              authority: 'special:user:detail',
              nav: 'userManage'
            },
            component: () =>
              import('../pages/userManage/page/organizationManage.vue')
          }
        ]
      },
      {
        path: '/statistics',
        name: 'statistics',
        redirect: '/statisticsMain',
        component: () => import('../pages/statistics'),
        meta: {
          name: '疫情信息统计',
          roles: [1]
        },
        children: [
          {
            path: '/statisticsMain',
            name: 'statisticsMain',
            component: () => import('../pages/statistics/components/statisticsMain'),
            meta: {
              authority: 'epidemic:manager:detail',
              nav: 'statistics'
            }
          }
        ]
      },
      {
        path: '/system',
        name: 'system',
        redirect: '/roleManage',
        component: () => import('../pages/system/system.vue'),
        meta: {
          name: '系统管理',
          roles: [1],
          childTitle: [
            '内部员工管理',
            '角色权限管理',
            'APP客户端管理'
          ],
          childPath: ['/roleManageMain', '/roleLimitManage', '/appClientManage']
        },
        children: [
          {
            path: '/roleManage',
            name: 'roleManage',
            redirect: '/roleManageMain',
            component: () => import('../pages/system/roleManage'),
            children: [
              {
                path: '/roleManageMain',
                name: 'roleManageMain',
                meta: {
                  fatherPath: 'system',
                  authority: 'sys:user:*',
                  nav: 'roleManage'
                },
                component: () => import('../pages/system/roleManage/page/roleManageMain')
              },
              {
                path: '/addRole',
                name: 'addRole',
                meta: {
                  fatherPath: 'system',
                  authority: 'sys:user:*',
                  nav: 'roleManage'
                },
                component: () => import('../pages/system/roleManage/page/addRole.vue')
              },
              {
                path: '/editRole',
                name: 'editRole',
                meta: {
                  fatherPath: 'system',
                  authority: 'sys:user:*',
                  nav: 'roleManage'
                },
                component: () => import('../pages/system/roleManage/page/editRole.vue')
              },
              {
                path: '/departManage',
                name: 'departManage',
                meta: {
                  fatherPath: 'system',
                  authority: 'sys:user:*',
                  nav: 'roleManage'
                },
                component: () =>
                  import('../pages/system/roleManage/page/departManage.vue')
              }
            ]
          },
          {
            path: '/roleLimitManage',
            name: 'roleLimitManage',
            redirect: '/roleLimitManageMain',
            component: () => import('../pages/system/roleLimitManage'),
            children: [
              {
                path: '/roleLimitManageMain',
                name: 'roleLimitManageMain',
                meta: {
                  fatherPath: 'system',
                  authority: 'sys:role:*',
                  nav: 'roleLimitManage'
                },
                component: () => import('../pages/system/roleLimitManage/page/roleLimitManageMain')
              },
              {
                path: '/addRoleLimitManage',
                name: 'addRoleLimitManage',
                meta: {
                  fatherPath: 'system',
                  authority: 'sys:role:*',
                  nav: 'roleLimitManage'
                },
                component: () => import('../pages/system/roleLimitManage/page/addRoleLimitManage.vue')
              }
            ]
          },
          {
            path: '/appClientManage',
            name: 'appClientManage',
            redirect: '/appMain',
            component: () => import('../pages/system/appClientManage'),
            children: [
              {
                path: '/appMain',
                name: 'appMain',
                meta: {
                  fatherPath: 'system',
                  authority: 'sys:app:*',
                  nav: 'appClientManage'
                },
                component: () => import('../pages/system/appClientManage/components/appMain')
              },
              {
                path: '/addClient',
                name: 'addClient',
                meta: {
                  fatherPath: 'system',
                  authority: 'sys:app:*',
                  nav: 'appClientManage'
                },
                component: () => import('../pages/system/appClientManage/components/addClient.vue')
              }
            ]
          }
        ]
      },
      {
        path: '/feedback',
        name: 'feedback',
        component: () => import('../pages/feedback/index.vue'),
        redirect: '/feedBackMain',
        meta: {
          name: '用户反馈',
          roles: [1]
        },
        children: [
          {
            path: '/feedBackMain',
            name: 'feedBackMain',
            component: () => import('@/pages/feedback/components/feedBackMain.vue'),
            meta: {
              authority: 'user:feedback:detail',
              nav: 'feedback'
            }
          }
        ]
      }
    ]
  }
]
const router = new VueRouter({
  base: '/backgroundManagement/',
  // base: process.env.BASE_URL,
  routes,
  mode: 'history'
})
export default router
